﻿@using LView.CMS.Models;
@model LExam;

<div class="layui-form">
    <div class="layui-col-lg8">
        @{
            var singleChooseQuestions = Model.ExamQuestions.Where(x => x.Type == 0);
            var mutliChooseQuestions = Model.ExamQuestions.Where(x => x.Type == 1);
            var trueOrFalseQuestions = Model.ExamQuestions.Where(x => x.Type == 2);
            var count = 1;
        }
        @if (singleChooseQuestions.Count() > 0)
        {
            <div class="layui-row layui-col-space10 singleQuesArea">
                <blockquote class="layui-elem-quote title">
                    <h2>单选题</h2>
                </blockquote>
                <div class="layui-elem-quote layui-quote-nm magb0">
                    @{
                        System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                    }
                    @foreach (var item in singleChooseQuestions)
                    {
                        <div class="layui-row">
                            <h3>@count . @item.Name</h3>
                            @foreach (var option in item.ExamOption)
                            {
                                var examOptionsIdx = item.ExamOption.IndexOf(option) + 1;
                                string optionFlag = asciiEncoding.GetString(new byte[] { (byte)(examOptionsIdx + 64) });
                                <div class="layui-row" style="padding-left:40px">
                                    <label class="layui-field-title layui-col-space10">@optionFlag : @option.Name</label>
                                </div>
                            }
                            <div class="layui-row layui-form-item" style="padding-left:5px">
                                @foreach (var option in item.ExamOption)
                                {
                                    var examOptionsIdx = item.ExamOption.IndexOf(option) + 1;
                                    string optionFlag = asciiEncoding.GetString(new byte[] { (byte)(examOptionsIdx + 64) });
                                    <input type="checkbox" title="@optionFlag">
                                }
                            </div>
                        </div>
                        count += 1;
                    }
                </div>
            </div>
        }
        @if (mutliChooseQuestions.Count() > 0)
        {
            <div class="layui-row layui-col-space10 mutliQuesArea">
                <blockquote class="layui-elem-quote title">
                    <h2>多选题</h2>
                </blockquote>
                <div class="layui-elem-quote layui-quote-nm magb0">
                    @{
                        System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                    }
                    @foreach (var item in mutliChooseQuestions)
                    {
                        <div class="layui-row">
                            <h3>@count . @item.Name</h3>
                            @foreach (var option in item.ExamOption)
                            {
                                var examOptionsIdx = item.ExamOption.IndexOf(option) + 1;
                                string optionFlag = asciiEncoding.GetString(new byte[] { (byte)(examOptionsIdx + 64) });
                                <div class="layui-row" style="padding-left:40px">
                                    <label class="layui-field-title layui-col-space10">@optionFlag : @option.Name</label>
                                </div>
                            }
                            <div class="layui-row layui-form-item" style="padding-left:5px">
                                @foreach (var option in item.ExamOption)
                                {
                                    var examOptionsIdx = item.ExamOption.IndexOf(option) + 1;
                                    string optionFlag = asciiEncoding.GetString(new byte[] { (byte)(examOptionsIdx + 64) });
                                    <input type="checkbox" title="@optionFlag">
                                }
                            </div>
                        </div>
                        count += 1;
                    }
                </div>
            </div>
        }
        @if (trueOrFalseQuestions.Count() > 0)
        {
            <div class="layui-row layui-col-space10 trueOrFalseQuesArea">
                <blockquote class="layui-elem-quote title">
                    <h2>判断题</h2>
                </blockquote>
                <div class="layui-elem-quote layui-quote-nm magb0">
                    @{
                        System.Text.ASCIIEncoding asciiEncoding = new System.Text.ASCIIEncoding();
                    }
                    @foreach (var item in trueOrFalseQuestions)
                    {
                        <div class="layui-row">
                            <h3>@count . @item.Name</h3>
                            @foreach (var option in item.ExamOption)
                            {
                                var examOptionsIdx = item.ExamOption.IndexOf(option) + 1;
                                string optionFlag = asciiEncoding.GetString(new byte[] { (byte)(examOptionsIdx + 64) });
                                <div class="layui-row" style="padding-left:40px">
                                    <label class="layui-field-title layui-col-space10">@optionFlag : @option.Name</label>
                                </div>
                            }
                            <div class="layui-row layui-form-item" style="padding-left:5px">
                                @foreach (var option in item.ExamOption)
                                {
                                    var examOptionsIdx = item.ExamOption.IndexOf(option) + 1;
                                    string optionFlag = asciiEncoding.GetString(new byte[] { (byte)(examOptionsIdx + 64) });
                                    <input type="checkbox" title="@optionFlag">
                                }
                            </div>
                        </div>
                        count += 1;
                    }
                </div>
            </div>
        }
    </div>
    <div class="layui-col-lg4">
        <div class="layui-row layui-col-space10 singleQuesArea" style="padding-left:20px">
            <blockquote class="layui-elem-quote title layui-row">
                <h2>答题卡<label> (共 @Model.ExamQuestions.Count()题)</label></h2>
            </blockquote>
            <div class="layui-elem-quote layui-quote-nm magb0">
                <div class="layui-row layui-form-item" style="padding-left:5px">
                    @foreach (var item in Model.ExamQuestions)
                    {
                        <input type="checkbox" title="@(Model.ExamQuestions.ToList().IndexOf(item)+1)">
                    }
                </div>
                <div class="layui-center">
                    <a class="layui-btn layui-btn-normal submitAnswer"><i class="layui-icon">&#xe609;</i>提交试卷</a>
                </div>
            </div>
            @*<div class="layui-elem-quote layui-quote-nm magb0 layui-center">*@

            @*</div>*@
        </div>
    </div>
</div>

<script type="text/javascript" src="~/layui/layui.js"></script>
<script>
    layui.use('form', function () {
        var form = layui.form;
    });
</script>
